;Tally Add-on : e-Way Bill Print Button
;This Add-on will enable to print e-Way Bill Separately from a button given in Sales voucher.

[#Part: CMP TallyShopFeatures Left]
	Add : Line  : 	 Enable_EwayBill_PrintSaparated
	Add : Line  : 	 Enable_EwayBill_PrintSaparated1
	Add : Line  : 	 Enable_EwayBill_PrintSaparated2

[Line :  Enable_EwayBill_PrintSaparated]
    Field : medium prompt, Enable_EwayBill_PrintSaparated
    Local : field : medium prompt : set as : "Enable e-Way Bill Print / Export Button Separately ?"
    Local : Field : Medium Prompt : width : 40
	
    space top : 0.2 cm

[Line :  Enable_EwayBill_PrintSaparated1]
    
    space top : 0.2 cm
	
	Field 	: medium prompt
	Local	: Field : medium prompt  : Set as 	: "(Ctrl + 1 to Print e-Way Bill from Sales Voucher)"
	Local	: Field : medium prompt  : Skip		: Yes
	Local	: Field : medium prompt  : Color	: Blue
	Local	: Field : medium prompt  : Style	: Small  Italic
	Local	: Field : medium prompt  : Full Width:Yes
	
	Indent	: 1
	
[Line :  Enable_EwayBill_PrintSaparated2]
    
    space top : 0.2 cm
	
	Field 	: medium prompt
	Local	: Field : medium prompt  : Set as 	: "(Ctrl + 2 to Export e-Way Bill from Sales Voucher)"
	Local	: Field : medium prompt  : Skip		: Yes
	Local	: Field : medium prompt  : Color	: Blue
	Local	: Field : medium prompt  : Style	: Small  Italic
	Local	: Field : medium prompt  : Full Width:Yes
	Indent	: 1


[Field :  Enable_EwayBill_PrintSaparated]
   Use 		: Logical field
   Storage 	: Enable_EwayBill_PrintSaparated
   Sub Form : EwayBill_Saparated_ExportPath : $Enable_EwayBill_PrintSaparated

[System: formula]
	EwayBill_Saparated_ExportPath 		: $EwayBill_Saparated_ExportPath:company:##svcurrentcompany
	
	Enable_EwayBill_PrintSaparated 		: $Enable_EwayBill_PrintSaparated:company:##svcurrentcompany 
	HVEnable_EwayBill_PrintSaparated 	: $Enable_EwayBill_PrintSaparated:voucherType:##SVVoucherType
	
	
[System: udf]
	Enable_EwayBill_PrintSaparated 	: Logical	: 1412
	EwayBill_Saparated_ExportPath 	: String 	: 1413

[Report:EwayBill_Saparated_ExportPath]
	Title:"e-Way Bill Export Path"
	Form:EwayBill_Saparated_ExportPath
	
[Form:EwayBill_Saparated_ExportPath]
	Part:EwayBill_Saparated_ExportPath
	Background:White
	
[Part:EwayBill_Saparated_ExportPath]
	Line:EwayBill_Saparated_ExportPath
	
[Line:EwayBill_Saparated_ExportPath]
	Field:Medium Prompt,EwayBill_Saparated_ExportPath
	Local:Field:Medium prompt : Set as:"Export Path"
	Local:Field:Medium prompt : Width:10
	
[Field:EwayBill_Saparated_ExportPath]
	Use:Name Field
	Storage:EwayBill_Saparated_ExportPath
	Validate:NOT $$IsEmpty:$$Value
	Width: 65
	
;[#Part: VTYP Main Left]
;	add :  Parts   : At End : HVEnable_EwayBill_PrintSaparated

[Part: HVEnable_EwayBill_PrintSaparated]
	Line	: HVEnable_EwayBill_PrintSaparated
	Local	: Field	: LongPrompt		: Width		: @@LongWidth + 5

[Line: HVEnable_EwayBill_PrintSaparated]
	Space Top: 2 mm
	Field: Long prompt,HVEnable_EwayBill_PrintSaparated
	Local: Field: Long prompt : Set as: "Enable e-Way Bill Print Button Separately ?"
			
	Invisible: not @@Enable_EwayBill_PrintSaparated

[Field: HVEnable_EwayBill_PrintSaparated]
	Use: logical field
	Storage: Enable_EwayBill_PrintSaparated
	
[System:Formulas]
	EwayBill_PrintSaparated_ExportMode	:  $$InExportMode OR $$InMailAction 

[#Report: Printed Invoice]
	Option: vEwayBill_PrintSaparatedOp : @@Enable_EwayBill_PrintSaparated and @@issales AND NOT @@EwayBill_PrintSaparated_ExportMode
	
[!Report:vEwayBill_PrintSaparatedOp]
	Local:Form : GSTeWayBillDEtails : Empty  :  Yes

;;Button
[#Form:Sales Color]
	Options:vEwayBill_PrintSaparated : @@Enable_EwayBill_PrintSaparated 

[!Form:vEwayBill_PrintSaparated]

	Add : Button : vEwayBill_PrintSaparatede ,vEwayBill_PrintSaparated , VchSendeWayBill_Export

[Button:vEwayBill_PrintSaparatede]

[Button:vEwayBill_PrintSaparated]
	Title	: "Print e-Way Bill"
	Key 	: Ctrl + 1
	Action	: Call:KeyPrintEwaybill
		
[Function : vEwayBill_PrintSaparated]
	
	Variable : VoucherID : String
	
	100 : 	EXECUTE : eWay_Bill_PrintCopiesPreviews
	
	130 : 	SET 	: SVVoucherType : $VoucherTypeName
	150 : 	SET 	: VoucherID : "ID:"+ $$String:$MasterId

	160 : 	PRINT 	: KeyPrintEwaybill : TRUE
	

[Report: eWay_Bill_PrintCopiesPreviews]
	Title	: "e-Way Bill Print"
	Form 	: eWay_Bill_PrintCopiesPreviews
	
[Form: eWay_Bill_PrintCopiesPreviews]
	Part 		: eWay_Bill_PrintCopiesPreviews
	Background  : White

[Part: eWay_Bill_PrintCopiesPreviews]
	;Line : eWay_Bill_PrintCopiesPreviews1
	Line : eWay_Bill_PrintCopiesPreviews2

	[Line: eWay_Bill_PrintCopiesPreviews1]

		Field : Medium Prompt,eWay_Bill_PrintCopiesPreviews1
		Local : Field : Medium Prompt : set As : "No. of Copies :"
	
[Field: eWay_Bill_PrintCopiesPreviews1]
	
	Use 		: Number Field
	Modifies 	: eWay_Bill_PrintCopiesPreviews
	
[Line : eWay_Bill_PrintCopiesPreviews2]
	
	Field : Medium Prompt,eWay_Bill_PrintCopiesPreviews2
	Local : Field : Medium Prompt : set As : "Show Preview ?"
		
[Field: eWay_Bill_PrintCopiesPreviews2]
	
	Use 		: Logical Field
	Modifies 	: SVPreview
	
[Variable: eWay_Bill_PrintCopiesPreviews]
	Type 		: Number
	Persistent 	: Yes

[System: Variable]
	eWay_Bill_PrintCopiesPreviews	: 0
	
[Button:VchSendeWayBill_Export]
	Key     : Ctrl + 2
	Title   : "Export e-Way Bill"
	Action	: Call :Export_eWayBillExportConfirm
	Inactive: $$IsEmpty:@@EwayBill_Saparated_ExportPath 
	
[Function: Export_eWayBillExportConfirm]
	20	: QUERY BOX : "Export e-Way Bill ?" 
 	30	: IF		: $$LastResult
 	40	: Call 		: Export_eWayBillExportConfirm2
	45	: ELSE 		: 
	50	: Break	
	55  : Endif

[Function: Export_eWayBillExportConfirm2]
	
	03	: SET	: SVExportFormat		: $$SysName:pdf
	04 	: Set  	: SVOpenFileAfterExport : No
	05 	: Set  	: SVExportLocation 		: @@EwayBill_Saparated_ExportPath
	
	06 	: Set  	: SVIsPortrait  		: Yes
	07 	: Set  	: SVBrowserHeight 		: 297
	08 	: Set  	: SVBrowserWidth 		: 210

	09	: SET  	: SVPrintFileName		: @@EwayBill_Saparated_ExportPath + "\"  + "e_WayBill" + "_" + @@GSTPrinteWayBillNumber +   ".pdf"
	
	13 	:  EXPORT REPORT 				: GSTeWayBillDEtails_Print : Yes: Yes
	

[Report:GSTeWayBillDEtails_Print]
;Use:Voucher

Print Set:Report Title  	: "e-Way Bill"
Set:Report Title  			: "e-Way Bill"
Print Set:ReportSubTitle 	: "e-Way Bill"
Print Set:SVPrintCopy       : If ##SVPrintCopies = 1 Then $$SysName:NotApplicable Else $$LocaleString:"All"
Print Set:SVPrintCopies  	: 1

Forms	: GSTeWayBillDEtails

;Empty 	: NOT @@VchIsGSTOn OR NOT (@@CMPIseWAyBillPrintApplicable AND @@VchPrintGSTeWayBillActive AND ##SVPrinteWayBillInvoice) OR NOT ((##IseWayPSPrintAfterSave OR ##IseInvPSPrintAfterSave) OR @@GSTeWayBillIsSystemDateAppl) OR @@IsMultiVchPOSInvoice
Empty   : $$IsEmpty:@@GSTeWayQRCodeBillGenDate ;OR NOT $$SETNO = ##SVPrintCopies


    Use				: VATNG Tringualtion Report_Variables 
	Use				: GST InvoiceAnalysis Report_Variables
    Use				: VATGCC InvAnalysis Report_Variables
	Use         	: STDInvoice
	
	PrintSet	    : Report Title		: If (NOT ##OptionalFlag AND @@IsSales AND NOT $$IsEmpty:$VCHPrintTitle:VoucherType:##SVVoucherType) then +
                                          $VCHPrintTitle:VoucherType:##SVVoucherType else If @@IsExciseMfgVchUnit AND ##IsExciseVoucher AND @@IsSales AND @@IsExciseSupplemInvoice Then $$LocaleString:"SUPPLEMENTARY INVOICE" Else +
                                          If (@@IsTraderExciseSalesDNUnit OR (@@IsExciseMfgVchUnit AND ##IsExciseVoucher AND ((@@IsSales OR @@IsDebitNote))) AND NOT ##SATraderCommercial) OR (@@IsExciseGoodsTransfer AND NOT @@VtypJobWorkEnabled AND NOT ##DNMfgrCommercial) Then $$LocaleString:"EXCISE INVOICE" Else +
                                          If (@@IsSales AND $$IsEmpty:##SATitle) OR (@@IsPurchase AND $$IsEmpty:##PUTitle) then $$LocaleString:"INVOICE" else  @@InvTitle
	PrintSet	    : Report SubTitle	: If (@@IsExcTaxenabledDate_Vch) AND (((@@IsTraderExciseSalesDNUnit OR (@@IsExciseMfgVchUnit AND ##IsExciseVoucher AND (@@IsSales OR @@IsDebitNote))) AND NOT ##SATraderCommercial) OR (@@IsExciseGoodsTransfer AND NOT @@VtypJobWorkEnabled AND NOT ##DNMfgrCommercial)) AND NOT @@IsExVchUsedForJewellery Then $$LocaleString:"(ISSUE OF INVOICE UNDER RULE 11 OF CENTRAL EXCISE RULES 2002)" Else +
                                          If (@@IsExcTaxenabledDate_Vch) AND (((@@IsExciseMfgVchUnit AND ##IsExciseVoucher AND (@@IsSales OR @@IsDebitNote)) AND NOT ##SATraderCommercial) OR (@@IsExciseGoodsTransfer AND NOT @@VtypJobWorkEnabled AND NOT ##DNMfgrCommercial)) AND @@IsExVchUsedForJewellery Then $$LocaleString:"(ISSUE OF INVOICE UNDER RULE 8 OF ARTICLES OF JEWELLERY (COLLECTION OF DUTY) RULES 2016)" Else +
                                          @@InvSubTitle
		
	Print Set   	: SVPrintCopy       : If ##SVPrintCopies = 1 Then $$SysName:NotApplicable Else $$LocaleString:"All"

	Variable		: vLocalLanguageID	: String	: @@ArabicLanguageId
	Variable		: GCCItemLanguageID	: String	: "67175425"
	
    Variable    	: vShowMsg          : Logical   : If $$InPrintAction AND (@@IsSales OR @@IsPurchase) Then +
														$$TaxMismatchWarn Else No
														
	Variable		: vShowDelRcptNoteMsg: Logical	: If $$InPrintAction AND (@@IsDelNote OR @@IsRcptNote) Then +
														$$DelRcptNoteWarn Else No
														
	Variable		: vGVATReportLang			: String	: ##vGVATPrintLanguage
		
	Set				: SVCurrentUILanguageId		: If @@VATGCCArabicPrintLang Then 1025 Else ##SVCurrentUILanguageId
	Set				: SVCurrentKBLanguageId		: If @@VATGCCArabicPrintLang Then 1025 Else ##SVCurrentKBLanguageId
	


	Set				: vShowSupplCrNote	: No
	
	ListVariable	: CVExciseDetailList

	;; Trader Invoice List Variable Declared
	List Variable 	: TraderInvoice	
	Variable	  	: IsVATCSTAnalysis
    List Variable 	: SVVATCSTAnalysisDetails
    List Variable 	: lvVchInclVATDutyDetails
	
	Option  		: GVAT Printed Invoice  : @@IsVChGVATApplicable
    
	Option		    : GST Printed Invoice			: @@VCHIsGSTRegularCompOnAndAppl
    
    ;Form		    : GST InvoiceWithItemAnalysis, GSTeWayBillDEtails
    Variable	    : vItemAnalysisCount    : Number

    Variable	    : vRcShowMsg		    : Logical   : If $$InPrintAction AND (@@IsSales OR @@IsPurchase) Then +
                                                          $$GSTRcNonRcWarn Else No
	Variable	    : vCompRcShowMsg	    : Logical   : If $$InPrintAction AND @@IsPurchase Then $$GSTCompRCNonRCWarning Else No

	Variable	    : STXReversalpercfound 		: Logical	:No
	Variable 	    : STXReversalperc			: Number
	Variable 	    : STXReversalAmounton		: Amount
	Variable	    : STXAbatementPerc			: Number
	Variable	    : STXRevNotficationdtls 	: String
	Variable	    : STXIsSalesHasAdvRcpt		: Logical	:No
	Variable	    : StxisRcptfullyConsumed	: Logical	:No
	Variable	    : StxIsVchHasCommonCat 		: Logical	:No
	Variable	    : StxReceiptAssableAmount	: Amount
	Variable	    : strCommonCatDesc			: String
	Variable	    : StrCatInfoFndat			: String
	Variable	    : vInvAbatementrate			: Number
	Variable	    : vInvReversalrate			: Number
	Variable	    : vInvExpenseAmount			: Amount
	Variable	    : vinvReversalNo			: String
	Variable	    : vinvExemptedno			: String
	Variable	    : IsPartybelongstoExempted	: Logical	: No
	Variable	    : StxexemptednotifyNo		: String
	Variable	    : IsInvexempted				: Logical	: No
	Variable	    : vIsBelongstonegative		: Logical	: NO
	Variable	    : vcatfound					: Logical	: No
	
	Variable	    : SVAdvRcptPaySBCAmount		: Amount	: 0
	Variable	    : SVAdvRcptPayKKCAmount		: Amount	: 0
    
	Variable	    : SVCurrentUILanguageId, SVCurrentKBLanguageId
	Variable	    : vGVATReportLang	: String	: ##vGVATPrintLanguage
            
	Set			    : SVCurrentUILanguageId		: If @@VATGCCArabicPrintLang Then 1025 Else ##SVCurrentUILanguageId
	Set			    : SVCurrentKBLanguageId		: If @@VATGCCArabicPrintLang Then 1025 Else ##SVCurrentKBLanguageId
    
	Variable	    : vLocalLanguageID	: String	: @@ArabicLanguageId
	Variable	    : GCCItemLanguageID	: String	: "67175425"
        
    List Var        : lvDutyHeads
    List Var        : lvDutyWiseTotal 
    List Var        : lvExciseExceptedDutyList, lvExciseItemWiseAssessableVal

    Pre Fetch Object: Tax unit : $Taxunitname : ExciseRegistrationType, ExciseMailingName, UseForJewellery
        
	Option	        : ExVchLedFetchObj		: @@IsExciseTraderOn


;; Select Print PrintEwayBillInfo
[#Menu:Gateway of Tally]
Add:Key Item:Before:@@LocBanking:"e-Way Bill Register":E:Display:GSTR EWB register
Add:Key Item:After:"e-Way Bill Register":""

[#Form:GSTR EWB Register]
Add:Button:GSTR EwaybillPrinte,GSTR EwaybillPrint

[Button:GSTR EwaybillPrinte]

[Key:GSTR EwaybillPrint]
Title:"Selected e-way Bill Print"
Action:Call:Select Print PrintEwayBillInfo
Keys:Alt+5

[Function:Select Print PrintEwayBillInfo]
Variables:VoucherID:String
Action:01:Walk Collection:Select Print PrintEwayBill
Action:00:Set:VoucherID:$$SPrintF:@@VCHMasterID:$MasterID
Action:02:Print:PrintEwayBillInfo
Action:03:End Walk

[Collection:Select Print PrintEwayBill]
Data Source:Report  : Selected
Native Method:*

[Report:PrintEwayBillInfo]
Use:Voucher
Use:Printed Invoice
Set:SVGSTEWBPrintCopies:##SVPrintCopy
Delete:Form
Add:Form:GSTeWayBillDEtails1


;[#Form:Sales Color]
;Add:Button:KeyPrintEwaybill

[Key:KeyPrintEwaybill]
Title:"Print E-way Bill"
Action:Call:KeyPrintEwaybill
Keys:Ctrl+Y
Inactive:@@PrintEwayBillSeprate and (NOT @@VchIsGSTOn OR NOT (@@CMPIseWAyBillPrintApplicable AND @@VchPrintGSTeWayBillActive AND ##SVPrinteWayBillInvoice) OR NOT ((##IseWayPSPrintAfterSave OR ##IseInvPSPrintAfterSave) OR @@GSTeWayBillIsSystemDateAppl))

[Function:KeyPrintEwaybill]
Variables:VoucherID:String
Action:01:Set:VoucherID:$$SPrintF:@@VCHMasterID:$MasterID
Action:02:Print:KeyPrintEwaybill

[Report:KeyPrintEwaybill]
Use:Voucher
Use:Printed Invoice
Set:SVGSTEWBPrintCopies:##SVPrintCopy
Delete:Form
Add:Form:GSTeWayBillDEtails1

[Form:GSTeWayBillDEtails1]

Use:VATNG VATCSTAnalysis Variables

Top Parts:GSTeWBPrn Header, GSTeWBPrn Details, GSTeWBPrn Addr, GSTeWBPrn Goods
Bottom Parts:GSTeWBPrn Tax, GSTeWBPrn Trans, GSTeWBPrn Vehicle

Width:@@InvWidth Inch
Height:@@InvHeight Inch

Space Top:@@InvSpace inch
Space Right:0.1 inch
Space Left:@@InvSpaceLeft  inch
Space Bottom:0.25 inch

Set Always:SVViewName : $$SysName:InvVchView

Options:GST InvoiceAnalysis

Options:Small Size form

Page Break:GSTeWayBillDEtails ClPageBreak, GSTeWayBillDEtails OpPageBreak

